home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / Imaging & Layout / Creating EmbeddedFramesIterator < prev    next >
Encoding:
Text File  |  1995-11-07  |  2.5 KB  |  55 lines  |  [TEXT/ttxt]

  1. OpenDoc™ Recipes
  2.  
  3. Creating an EmbeddedFramesIterator
  4. By The OpenDoc Design Team
  5. 7 November, 1995
  6.  
  7.  
  8. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  9. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  10. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  11.  
  12.  
  13. Parts and EmbeddedFramesIterators
  14.  
  15. Part editors must be able to create iterators for their embedded frames. When a part receives a CreateEmbeddedFramesIterator call, it should create the iterator and return it.
  16.  
  17.  
  18. Creating the iterator
  19.  
  20. The part editor library will include implementations for subclasses of ODPart and ODEmbeddedFramesIterator, and perhaps other extensions as well. To create the embedded frames iterator the part just allocates and initializes the instance.
  21.  
  22. The API for ODCreateEmbeddedFramesIterator is somewhat awkward to use, due to a missing parameter in the Init call.  The iterator should only operate on the embedded frames of a particular display frame of the part. However, the InitEmbeddedFramesIterator call only takes an ODPart parameter, and not an ODFrame parameter. Therefore, whatever private interface between the iterator and the part that allows the iterator access to the embedded frames, it must be able to handle the mapping to the particular frame.
  23.  
  24. For instance, after calling InitEmbeddedFramesIterator, the part could make another call to the iterator to let it know which frame it is operating on. Then the iterator would pass the frame back to the part to get the right embedded frames to iterate. Alternately, the part could just remember the mapping of the iterator to the frame, and the iterator could pass itself instead of the frame.
  25.  
  26. Caveats
  27.  
  28. • This code does not contain proper error checking
  29. • The OrderedCollection class is a private utility, the implementation is an exercise left for the reader.
  30.  
  31.  
  32. Sample Code
  33.  
  34. MyEmbeddedFramesIterator* CMyPart::CreateEmbeddedFramesIterator(Environment* ev, ODFrame* frame)
  35. {
  36.    MyEmbeddedFramesIterator* iter = new MyEmbeddedFramesIterator;
  37.    this->MapFrameIterator(iter, frame);
  38.    iter->InitEmbeddedFramesIterator(ev, somSelf);
  39.    return iter;
  40. }
  41.  
  42. OrderedCollection* CMyPart::GetEmbeddedFrames(Environment* ev, MyEmbeddedFramesIterator* iter)
  43. {
  44.    ODFrame* frame = this->GetFrameForIter(ev, iter);
  45.    OrderedCollection* frameList = this->GetEmbeddedListOfFrame(ev, frame);
  46.    return frameList;
  47. }
  48.  
  49. void MyEmbeddedFramesIterator::InitEmbeddedFramesIterator(Environment* ev, ODPart* part)
  50. {
  51.        fPrivateIter = ((CMyPart*)part)->GetEmbeddedFrames(ev, this)->CreateIterator();
  52. }
  53.  
  54.  
  55.